package com.cxy.juc;

public class SynchronizedTwo {
    public static void main(String[] args) {
        TestTwo test1 = new TestTwo();
        TestTwo test2 = new TestTwo();
        Thread t1 = new Thread(test1,"thread-1");
        Thread t2 = new Thread(test2,"thread-2");
        t1.start();
        t2.start();
    }
}

class TestTwo implements Runnable {
    @Override
    public void run() {
        synchronized (this) {
            for (int i = 0; i < 5; i++) {
                System.out.println(Thread.currentThread().getName()+"--->"+i);
            }
        }
    }
}


